﻿$(document).ready(function () {

    var GobackTimer = parseInt($("#GobackTimer").val());
    var countdown = null;

    function timeShow() {
        GobackTimer--;
        $(".countdown").html("倒计时" + GobackTimer + "秒");
        if (GobackTimer < 1) {
            clearInterval(countdown);
            //$(".countdown").html("倒计时结束！！");
            window.opener = null;
            window.location.href = "SelfService.aspx";
        }
    };

    window.ShowLoginForm = function () {

        var loginForm = $('.readerlogin-form');
             loginForm.show();
            header.removeClass('headernormal').addClass('headerlogin');
            mask.fadeIn();
  
    }

    var CanContinue = 0;

    var interval = 1500;   //number of mili seconds between each call
    var refresh = function () {
        $.ajax({
            url: "AjaxSelfService.aspx",

            data: {
                Action: $("#Action").val()
            },

            cache: false,

            success: function (contents) {
                //alert(html);

                if (contents == "@reload") {
                    location.reload();
                    return;
                }

                if (contents.length > 10) {
                    CanContinue = 1;
                    $("#AjaxContent").html(contents);

                }

                if (CanContinue == 0) {
                    setTimeout(function () {
                        refresh();
                    }, interval);
                }


            }
        });




    };

    refresh();

    if (GobackTimer > 0)
        countdown = setInterval(timeShow, 1000);

});